﻿using System;
using System.Drawing;

namespace ShapeManager
{
    public class UEllipse : URectangle
    {
        public UEllipse() : this(0, 0, 1, 1) { }
        public UEllipse(int x, int y, int width, int height) : base()
        {
            Region = new Rectangle(x, y, width, height);
            Type = ShapeType.Ellipse;
            Description = "椭圆";
            Initialize();
        }
        public override DrawObject Clone()
        {
            UEllipse uEllipse = new UEllipse();
            uEllipse.Region = this.Region;
            uEllipse.ID = this.ID;
            Clone(uEllipse);
            return uEllipse;
        }
        public override void Draw(Graphics graphics)
        {
            using (Pen pen = new Pen(BorderColor, BorderWidth))
            {
                graphics.DrawEllipse(pen, URectangle.GetNormalizedRectangle(Region));
            }
            if (!IsInterest)
            {
                using (Brush brush = new SolidBrush(Color.FromArgb(Alpha, BorderColor)))
                {
                    graphics.FillEllipse(brush, URectangle.GetNormalizedRectangle(Region));
                }
            }
            if (IsInterest && IsSelected)
            {
                using (Brush brush = new SolidBrush(Color.FromArgb(Alpha, BorderColor)))
                {
                    graphics.FillEllipse(brush, URectangle.GetNormalizedRectangle(Region));
                }
            }
            DrawCenter(graphics);
            DrawDescription(graphics);
        }
    }
}
